<?php
namespace Admin\Controller;
use Think\Controller;
/* 
 *Login后台登录界面 
 *  
 *  
 */
class LoginController extends Controller{
    function login() {
   
    
    
 
             if (!empty($_POST)) {
                $name=$_POST['name'];
                $email=$_POST['email'];
                 
                if(mb_strlen($name)<1 || mb_strlen($name)>15) {
                    $this->ajaxReturn(array('pass'=>0,'msg'=>'请输入合法的名称  ！'));
                }
                $login=M('User');
                $where['name']=$name;
                $where['email']=$email;
                 
                $re=$login->where("name='%s' and email='%s'",array($name,$email))->find();
                

                if ($re) {
                    setcookie('id',$re['id'],0,'/');
                    setcookie('name',$name,0,'/');
                    $this->ajaxReturn(array('pass'=>1,'msg'=>'登录成功！'));
                     
                }else {
                    $this->ajaxReturn(array('pass'=>2,'msg'=>'登录失败！'));
                     
                }
                 
                 
            }
            $this->display();
        }
    }
